package com.company.bilibili;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[4];
        for (int i = 0; i < 4 ; i++) {
            num[i] = sc.nextInt();
        }
        System.out.println(Game24Points(num));

    }

    public static boolean Game24Points (int[] arr) {
        // write code here
        List<List<Integer>> res = new ArrayList<>();
        List<Integer> list = new ArrayList<>();
        boolean[] isUsed = new boolean[4];
        getAll(res,list,isUsed,arr);
        for(int i = 0;i < res.size();i++){
            List<Integer> s = res.get(i);
            int a = s.get(0);
            int b =s.get(1);
            int c = s.get(2);
            int d = s.get(3);
            if(a + b + c + d == 24){
                return true;
            }
            if(a + b + c - d == 24){
                return true;
            }
            if(a + b + c * d == 24){
                return true;
            }
            if(a + b + c / d == 24){
                return true;
            }

            if(a - b + c - d == 24){
                return true;
            }
            if(a * b + c - d == 24){
                return true;
            }
            if(a / b + c - d == 24){
                return true;
            }



            if(a + b - c - d == 24){
                return true;
            }
            if(a + b * c - d == 24){
                return true;
            }
            if(a + b / c - d == 24){
                return true;
            }

        }
        return false;


    }

    private static void getAll(List<List<Integer>> res,List<Integer> list,boolean[] isUsed,int[] arr){
        for(int i = 0;i < 4;i++){
            list.add(arr[i]);
            isUsed[i] = true;
            for (int j = 0; j < 4; j++) {
                if(isUsed[j] ){
                    continue;
                }
                isUsed[j] = true;
                list.add(arr[j]);
                for (int k = 0;k < 4;k++){
                    if(isUsed[k]){
                        continue;
                    }
                    isUsed[k] = true;
                    list.add(arr[k]);
                    for (int l = 0; l  < 4 ; l++) {
                        if(isUsed[l]){
                            continue;
                        }
                        isUsed[l] = true;
                        list.add(arr[l]);
                        res.add(new ArrayList<>(list));
                        list.remove(list.size()-1);
                        isUsed[l] = false;
                    }
                    list.remove(list.size()-1);
                    isUsed[k] = false;
                }
                list.remove(list.size()-1);
                isUsed[j] = false;
            }
            list.remove(list.size()-1);
            isUsed[i] = false;
        }
    }
}
